/**
 * UVa 105 UVa 105 The Skyline Problem
 * Author: chchwy
 * Last Modified: 2008.11.27
 * Tag: Brute Force
 */
#include <cstdio>
#include <cstring>

int main()
{
#ifndef ONLINE_JUDGE
    freopen("105.in","r",stdin);
#endif

    int height_map[10000+1];
    int rightMost = 0; // the right most position of buildings

    memset(height_map, 0, sizeof(height_map));

    // L,H,R of a building
    int left, height, right;
    while (scanf("%d %d %d", &left, &height, &right) == 3) {

        for (int i = left; i < right; ++i) {
            if (height > height_map[i])
                height_map[i] = height;
        }
        if (right > rightMost)
            rightMost = right;
    }

    //output
    int prev_height = 0;
    for (int i = 0; i < rightMost; ++i) {
        if (height_map[i] == prev_height)
            continue;
        printf("%d %d ", i, height_map[i]);
        prev_height = height_map[i];
    }
    printf("%d %d\n", rightMost, 0);
    return 0;
}
